﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DTO;
using DataService;

public partial class Admin_Default : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (AdminLogin == null)
            Response.Redirect("~/admin/login.aspx");

        if (!IsPostBack)
        {
            Inittial();
        }
    }

    private void Inittial()
    {
        gvCustomers.DataSource = (new AdminService()).GetCustomers();
        DataBind();
    }
    protected void gvCustomers_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        AdminService service = new AdminService();

        if (e.CommandName.ToUpper() == "Delete".ToUpper())
        {
            try
            {
                int AccountId = Convert.ToInt32(e.CommandArgument);
                service = new AdminService();
                service.DeleteAccountByAccountId(AccountId);
                Inittial();
            }
            catch
            {
                Response.Write("<script>alert('Exception')</script>");
            }
            
        }          
    }
    protected void gvCustomers_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {

    }
}